#include "TensorStack.h"

TensorStack::TensorStack()
{
}

TensorStack::~TensorStack()
{
}

void TensorStack::AddTensor(std::string layerName, const DL::Tensor1D<float>& tensor)
{
	unsigned int* bytes = new unsigned int[tensor.width];
	memccpy(bytes, tensor.GetDataPtr(), 0, tensor.width * sizeof(float));
	TensorHeader header = {
		layerName,
		TensorType::FLOAT_FP32,
		0,
		0,
		0,
		tensor.width,
		QType::Non,
		0,
		0,
		bytes
	};
	infos.push_back(header);
}

void TensorStack::AddTensor(std::string layerName, const DL::Tensor2D<float>& tensor)
{
	unsigned int size = tensor.width * tensor.height;
	unsigned int* bytes = new unsigned int[size];
	memccpy(bytes, tensor.GetDataPtr(), 0, size * sizeof(float));
	TensorHeader header = {
		layerName,
		TensorType::FLOAT_FP32,
		0,
		0,
		tensor.height,
		tensor.width,
		QType::Non,
		0,
		0,
		bytes
	};
	infos.push_back(header);
}

void TensorStack::AddTensor(std::string layerName, const DL::Tensor3D<float>& tensor)
{
	unsigned int size = tensor.width * tensor.height * tensor.channel;
	unsigned int* bytes = new unsigned int[size];
	memccpy(bytes, tensor.GetDataPtr(), 0, size * sizeof(float));
	TensorHeader header = {
		layerName,
		TensorType::FLOAT_FP32,
		0,
		tensor.channel,
		tensor.height,
		tensor.width,
		QType::Non,
		0,
		0,
		bytes
	};
	infos.push_back(header);
}

void TensorStack::AddTensor(std::string layerName, const DL::Tensor4D<float>& tensor)
{
	unsigned int size = tensor.framePiexlCount;
	unsigned int* bytes = new unsigned int[size];
	memccpy(bytes, tensor.GetDataPtr(), 0, size * sizeof(float));
	TensorHeader header = {
		layerName,
		TensorType::FLOAT_FP32,
		tensor.deepth,
		tensor.channel,
		tensor.height,
		tensor.width,
		QType::Non,
		0,
		0,
		bytes
	};
	infos.push_back(header);
}
void TensorStack::AddTensor(std::string layerName, const DL::Tensor1D<int8>& tensor)
{
	unsigned int* bytes = new unsigned int[tensor.width];
	memccpy(bytes, tensor.GetDataPtr(), 0, tensor.width * sizeof(int8));
	TensorHeader header = {
		layerName,
		TensorType::INT_INT8,
		0,
		0,
		0,
		tensor.width,
		QType::Non,
		0,
		0,
		bytes
	};
	infos.push_back(header);
}

void TensorStack::AddTensor(std::string layerName, const DL::Tensor2D<int8>& tensor)
{

}

void TensorStack::AddTensor(std::string layerName, const DL::Tensor3D<int8>& tensor)
{
}

void TensorStack::AddTensor(std::string layerName, const  DL::Tensor4D<int8>& tensor)
{
}

